package Gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;

public class NavigationPanel extends JPanel{


	public NavigationPanel() {
		this.setBackground(new Color(124,51,84));
		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
		
	}

	public void addMenuItem(JPanel panel) {
		JButton button = addNewButtonToMenuAndReturnIt(panel.getName());
		addActionLisener(button,panel);
		
		
	}
	
	public JButton addNewButtonToMenuAndReturnIt(String panelName) {
		JButton button = new JButton(panelName);
		add(button);
		return button;
		
		
	}
	
	public void addActionLisener(final JButton button, final JPanel panel) {
		button.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				Controller controller = Controller.getInstance();
				
				controller.getContentViewPanel().removeAll();
				
				controller.getContentViewPanel().revalidate();
				controller.getMainFrame().repaint();
				System.out.println(button.getText());
				System.out.println(panel.getName());
				
				System.out.println("klick");
				
				
			}
		});
	
	}	

}
